Define open_timeout
for get_ec2_metadata_region
#173
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While developing some AMI provisioning tools locally, we attempt to
install the CodeDeploy agent. Unfortunately, the process was hanging
indefinitely.
Digging into the process using
strace
, it is stuck on aconnect
tothe EC2 metadata service.
This is due to the metadata service not being present in our local
development environment and the installer isn't able to resolve the
service.
After locating this in the installation script, I can see there is a
(very high) read timeout however there isn't an open timeout which is
what the process will use to restrict the amount of time a connection
can be pending a connection. This is particularly useful if the service
you are attempting to connect to is either unresponsive to accept the
connection or not reachable due to things like DNS resolution.
To address the issue, I've added an open timeout to the
open
call andnow the process fails as expected after a sensible 3s.
Included in this PR is a change extracting out the HTTP options that are
shared by the OpenURI
read
/open
calls to consolidate theconfiguration. This also introduces an
open_timeout
to thesesettings to mitigate the potential issue for these calls in the event
the service is unreachable for whatever reason.